//
//  main.m
//  Property修饰符
//
//  Created by wenjim on 17/10/3.
//  Copyright © 2017年 WenJim. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "Person.h"

int main(int argc, const char * argv[]) {
    
    Person * p = [[Person alloc] init];
    
    Room * r = [[Room alloc] init];
    
    
    /*
    Car * c = [[Car alloc] init];
    
    Dog * d = [[Dog alloc] init];
    
    
    p.room = r;
    p.car = c;
    p.dog = d;
    
    
    [d release];
    [c release];
    [r release];
    [p release];
    */
    
    
    p.room = r;
    [r release];
    
    // 换房了，如果setter方法中没有release旧值，就会内存泄露
//    Room * r2 = [[Room alloc] init];
//    p.room = r2;
//    [r2 release];
    
    // 重复赋值
    p.room = r;
    
    [p release];
    
    return 0;
}
